package o;

import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;

public final class anf {
    private byte[] ˊ;
    private int ˋ;
    private int ˎ;
    private int ˏ;

    public anf(byte[] bArr, int i, int i2) {
        ˊ(bArr, i, i2);
    }

    public void ˊ(byte[] bArr, int i, int i2) {
        this.ˊ = bArr;
        this.ˋ = i;
        this.ˎ = i2;
        this.ˏ = 0;
        ʽ();
    }

    public void ˊ() {
        int i = this.ˏ + 1;
        this.ˏ = i;
        if (i == 8) {
            this.ˏ = 0;
            this.ˋ = (ˊ(this.ˋ + 1) ? 2 : 1) + this.ˋ;
        }
        ʽ();
    }

    public void ˋ(int i) {
        int i2 = this.ˋ;
        int i3 = i / 8;
        this.ˋ += i3;
        this.ˏ = (i - (i3 * 8)) + this.ˏ;
        if (this.ˏ > 7) {
            this.ˋ++;
            this.ˏ -= 8;
        }
        i2++;
        while (i2 <= this.ˋ) {
            if (ˊ(i2)) {
                this.ˋ++;
                i2 += 2;
            }
            i2++;
        }
        ʽ();
    }

    public boolean ˎ(int i) {
        int i2 = this.ˋ;
        int i3 = i / 8;
        int i4 = this.ˋ + i3;
        i3 = (this.ˏ + i) - (i3 * 8);
        if (i3 > 7) {
            i4++;
            i3 -= 8;
        }
        int i5 = i2 + 1;
        i2 = i4;
        i4 = i5;
        while (i4 <= i2 && i2 < this.ˎ) {
            if (ˊ(i4)) {
                i2++;
                i4 += 2;
            }
            i4++;
        }
        return i2 < this.ˎ || (i2 == this.ˎ && i3 == 0);
    }

    public boolean ˎ() {
        boolean z = (this.ˊ[this.ˋ] & (DnsConfig.MAX_CACHE_ENTRIES >> this.ˏ)) != 0;
        ˊ();
        return z;
    }

    public int ˏ(int i) {
        int i2 = 2;
        this.ˏ += i;
        int i3 = 0;
        while (this.ˏ > 8) {
            this.ˏ -= 8;
            i3 |= (this.ˊ[this.ˋ] & 255) << this.ˏ;
            this.ˋ = (ˊ(this.ˋ + 1) ? 2 : 1) + this.ˋ;
        }
        i3 = (i3 | ((this.ˊ[this.ˋ] & 255) >> (8 - this.ˏ))) & (-1 >>> (32 - i));
        if (this.ˏ == 8) {
            this.ˏ = 0;
            int i4 = this.ˋ;
            if (!ˊ(this.ˋ + 1)) {
                i2 = 1;
            }
            this.ˋ = i4 + i2;
        }
        ʽ();
        return i3;
    }

    public boolean ˋ() {
        boolean z;
        int i = this.ˋ;
        int i2 = this.ˏ;
        int i3 = 0;
        while (this.ˋ < this.ˎ && !ˎ()) {
            i3++;
        }
        if (this.ˋ == this.ˎ) {
            z = true;
        } else {
            z = false;
        }
        this.ˋ = i;
        this.ˏ = i2;
        if (z || !ˎ((i3 * 2) + 1)) {
            return false;
        }
        return true;
    }

    public int ॱ() {
        return ॱॱ();
    }

    public int ˏ() {
        int ॱॱ = ॱॱ();
        return (ॱॱ % 2 == 0 ? -1 : 1) * ((ॱॱ + 1) / 2);
    }

    private int ॱॱ() {
        int i = 0;
        int i2 = 0;
        while (!ˎ()) {
            i2++;
        }
        int i3 = (1 << i2) - 1;
        if (i2 > 0) {
            i = ˏ(i2);
        }
        return i3 + i;
    }

    private boolean ˊ(int i) {
        return 2 <= i && i < this.ˎ && this.ˊ[i] == (byte) 3 && this.ˊ[i - 2] == (byte) 0 && this.ˊ[i - 1] == (byte) 0;
    }

    private void ʽ() {
        boolean z = this.ˋ >= 0 && (this.ˋ < this.ˎ || (this.ˋ == this.ˎ && this.ˏ == 0));
        amm.ˏ(z);
    }
}
